<?php
namespace CountLike\Controller;
use Common\Controller\CountLikeController;
class TestController extends CountLikeController {



    /**
     * 10以下'加'对的
     */
    public function fadd(){
        exit;
        $arr1 = array(0,1,2,3,4,5,6,7,8,9);
        $arr2 = array(0,1,2,3,4,5,6,7,8,9);

        for ($k=0;$k<=100;$k++){
            $i=array_rand($arr1);
            $p = array_rand($arr2);

            $sum = $arr1[$i] + $arr2[$p];
            $data = array(
                'leftnum'=>$arr1[$i],
                'rightnum'=>$arr2[$p],
                'symbol1'=>'+',
                'symbol2'=>'=',
                'sum'=>$sum,
                'rightsum'=>$sum,
                'anwser'=>'yes',
                'category'=>'1',
                'rank'=>'1',
            );

            M('countlike_questions')->data($data)->add();
          
            echo $arr1[$i].'+'.$arr2[$p].'='.$sum.'<br>';

        }


    }

//    public function xiuzheng(){
//
//        $where['game_num'] = array('lt',0);
//        M('countlike_member')->where($where)->save(array('game_num'=>'0'));
//
//    }
    /**
     * 10以下'-'对的
     */
    public function fjian(){
       exit;
        $arr1 = array(0,1,2,3,4,5,6,7,8,9);
        $arr2 = array(0,1,2,3,4,5,6,7,8,9);

        for ($k=0;$k<=100;$k++){
            $i=array_rand($arr1);
            $p = array_rand($arr2);

            $sum = $arr1[$i] - $arr2[$p];
            $data = array(
                'leftnum'=>$arr1[$i],
                'rightnum'=>$arr2[$p],
                'symbol1'=>'-',
                'symbol2'=>'=',
                'sum'=>$sum,
                'rightsum'=>$sum,
                'anwser'=>'yes',
                'category'=>'2',
                'rank'=>'1',
            );

            M('countlike_questions')->data($data)->add();

            echo $arr1[$i].'-'.$arr2[$p].'='.$sum.'<br>';

        }


    }

    /**
     * 10以下'+'错的
     */
    public function cadd(){
       exit;
        $arr1 = array(0,1,2,3,4,5,6,7,8,9);
        $arr2 = array(0,1,2,3,4,5,6,7,8,9);

        for ($k=0;$k<=100;$k++){
            $i=array_rand($arr1);
            $p = array_rand($arr2);

            $rightsum = $arr1[$i] + $arr2[$p];
            if ($k<=100){
                $sum = $rightsum+2;
            }
            if ($k<=75){
                $sum = $rightsum+1;
            }
            if ($k<=50){
                $sum = $rightsum-2;
            }
            if ($k<=30){
                $sum = $rightsum-1;
            }


            $data = array(
                'leftnum'=>$arr1[$i],
                'rightnum'=>$arr2[$p],
                'symbol1'=>'+',
                'symbol2'=>'=',
                'sum'=>$sum,
                'rightsum'=>$rightsum,
                'anwser'=>'no',
                'category'=>'1',
                'rank'=>'1',
            );

            M('countlike_questions')->data($data)->add();

            echo $arr1[$i].'+'.$arr2[$p].'='.$sum.'<br>';

        }


    }

    /**
     * 10以下'-'错的
     */
    public function cjian(){
       exit;
        $arr1 = array(0,1,2,3,4,5,6,7,8,9);
        $arr2 = array(0,1,2,3,4,5,6,7,8,9);

        for ($k=0;$k<=100;$k++){
            $i=array_rand($arr1);
            $p = array_rand($arr2);

            $rightsum = $arr1[$i] - $arr2[$p];
            if ($k<=100){
                $sum = $rightsum+2;
            }
            if ($k<=75){
                $sum = $rightsum+1;
            }
            if ($k<=50){
                $sum = $rightsum-2;
            }

            if ($k<=30){
                $sum = $rightsum-1;
            }


            $data = array(
                'leftnum'=>$arr1[$i],
                'rightnum'=>$arr2[$p],
                'symbol1'=>'-',
                'symbol2'=>'=',
                'sum'=>$sum,
                'rightsum'=>$rightsum,
                'anwser'=>'no',
                'category'=>'2',
                'rank'=>'1',
            );

            M('countlike_questions')->data($data)->add();

            echo $arr1[$i].'-'.$arr2[$p].'='.$sum.'<br>';

        }


    }

    /**
     * 10到20'-'对的
     */
    public function sjian(){

       exit;
        $arr1 = array(10,11,12,13,14,15,16,17,18,19);
        $arr2 = array(10,11,12,13,14,15,16,17,18,19);

        for ($k=0;$k<=100;$k++){
            $i=array_rand($arr1);
            $p = array_rand($arr2);

            $sum = $arr1[$i] - $arr2[$p];
            $data = array(
                'leftnum'=>$arr1[$i],
                'rightnum'=>$arr2[$p],
                'symbol1'=>'-',
                'symbol2'=>'=',
                'sum'=>$sum,
                'rightsum'=>$sum,
                'anwser'=>'yes',
                'category'=>'2',
                'rank'=>'2',
            );

            M('countlike_questions')->data($data)->add();

            echo $arr1[$i].'-'.$arr2[$p].'='.$sum.'<br>';

        }


    }

    /**
     * 10到20'+'对的
     */
    public function sadd(){
       exit;
        $arr1 = array(10,11,12,13,14,15,16,17,18,19);
        $arr2 = array(10,11,12,13,14,15,16,17,18,19);

        for ($k=0;$k<=100;$k++){
            $i=array_rand($arr1);
            $p = array_rand($arr2);

            $sum = $arr1[$i] + $arr2[$p];
            $data = array(
                'leftnum'=>$arr1[$i],
                'rightnum'=>$arr2[$p],
                'symbol1'=>'+',
                'symbol2'=>'=',
                'sum'=>$sum,
                'rightsum'=>$sum,
                'anwser'=>'yes',
                'category'=>'1',
                'rank'=>'2',
            );

            M('countlike_questions')->data($data)->add();

            echo $arr1[$i].'+'.$arr2[$p].'='.$sum.'<br>';

        }


    }

    /**
     * 10到20'-'错的
     */
    public function scjian(){
        exit;
        $arr1 = array(10,11,12,13,14,15,16,17,18,19);
        $arr2 = array(10,11,12,13,14,15,16,17,18,19);

        for ($k=0;$k<=100;$k++){
            $i=array_rand($arr1);
            $p = array_rand($arr2);

            $rightsum = $arr1[$i] - $arr2[$p];
            if ($k<=100){
                $sum = $rightsum+2;
            }
            if ($k<=75){
                $sum = $rightsum+1;
            }
            if ($k<=50){
                $sum = $rightsum-2;
            }
            if ($k<=30){
                $sum = $rightsum-1;
            }





            $data = array(
                'leftnum'=>$arr1[$i],
                'rightnum'=>$arr1[$p],
                'symbol1'=>'-',
                'symbol2'=>'=',
                'sum'=>$sum,
                'rightsum'=>$rightsum,
                'anwser'=>'no',
                'category'=>'2',
                'rank'=>'2',
            );

            M('countlike_questions')->data($data)->add();

            echo $arr1[$i].'-'.$arr2[$p].'='.$sum.'<br>';

        }


    }


    /**
     * 10到20'+'错的
     */
    public function scadd(){
       exit;
        $arr1 = array(10,11,12,13,14,15,16,17,18,19);
        $arr2 = array(10,11,12,13,14,15,16,17,18,19);

        for ($k=0;$k<=100;$k++){
            $i=array_rand($arr1);
            $p = array_rand($arr2);

            $rightsum = $arr1[$i] + $arr2[$p];
            if ($k<=100){
                $sum = $rightsum+2;
            }
            if ($k<=75){
                $sum = $rightsum+10;
            }
            if ($k<=50){
                $sum = $rightsum-2;
            }

            if ($k<=30){
                $sum = $rightsum-10;
            }


            $data = array(
                'leftnum'=>$arr1[$i],
                'rightnum'=>$arr2[$p],
                'symbol1'=>'+',
                'symbol2'=>'=',
                'sum'=>$sum,
                'rightsum'=>$rightsum,
                'anwser'=>'no',
                'category'=>'1',
                'rank'=>'2',
            );

            M('countlike_questions')->data($data)->add();

            echo $arr1[$i].'+'.$arr2[$p].'='.$sum.'<br>';

        }


    }


    /**
     * 20以上'+'错的
     */
    public function tcadd(){
        exit;
        for ($j=21;$j<100;$j++){
            $arr1[] = $j;
            $arr2[] = $j;
        }

        for ($k=0;$k<=100;$k++){
            $i=array_rand($arr1);
            $p = array_rand($arr2);

            $rightsum = $arr1[$i] + $arr2[$p];
            if ($k<=100){
                $sum = $rightsum+2;
            }
            if ($k<=75){
                $sum = $rightsum+10;
            }
            if ($k<=50){
                $sum = $rightsum-2;
            }

            if ($k<=30){
                $sum = $rightsum-10;
            }


            $data = array(
                'leftnum'=>$arr1[$i],
                'rightnum'=>$arr2[$p],
                'symbol1'=>'+',
                'symbol2'=>'=',
                'sum'=>$sum,
                'rightsum'=>$rightsum,
                'anwser'=>'no',
                'category'=>'1',
                'rank'=>'3',
            );

            M('countlike_questions')->data($data)->add();

            echo $arr1[$i].'+'.$arr2[$p].'='.$sum.'<br>';

        }


    }


    /**
     * 20以上'-'错的
     */
    public function tcjian(){
        exit;
        for ($j=31;$j<100;$j++){
            $arr1[] = $j;
            $arr2[] = $j;
        }

        for ($k=0;$k<=100;$k++){
            $i=array_rand($arr1);
            $p = array_rand($arr2);

            $rightsum = $arr1[$i] - $arr2[$p];
            if ($k<=100){
                $sum = $rightsum+10;
            }

            if ($k<=50){
                $sum = $rightsum-10;
            }


            $data = array(
                'leftnum'=>$arr1[$i],
                'rightnum'=>$arr2[$p],
                'symbol1'=>'-',
                'symbol2'=>'=',
                'sum'=>$sum,
                'rightsum'=>$rightsum,
                'anwser'=>'no',
                'category'=>'2',
                'rank'=>'3',
            );

            M('countlike_questions')->data($data)->add();

            echo $arr1[$i].'-'.$arr2[$p].'='.$sum.'<br>';

        }


    }

    /**
     * 20+'+'对的
     */
    public function tadd(){
        exit;
        for ($j=31;$j<100;$j++){
            $arr1[] = $j;
            $arr2[] = $j;
        }

        for ($k=0;$k<=100;$k++){
            $i=array_rand($arr1);
            $p = array_rand($arr2);

            $sum = $arr1[$i] + $arr2[$p];
            $data = array(
                'leftnum'=>$arr1[$i],
                'rightnum'=>$arr2[$p],
                'symbol1'=>'+',
                'symbol2'=>'=',
                'sum'=>$sum,
                'rightsum'=>$sum,
                'anwser'=>'yes',
                'category'=>'1',
                'rank'=>'3',
            );

            M('countlike_questions')->data($data)->add();

            echo $arr1[$i].'+'.$arr2[$p].'='.$sum.'<br>';

        }


    }

    /**
     * 20+'-'对的
     */
    public function tjian(){
       exit;
        for ($j=31;$j<100;$j++){
            $arr1[] = $j;
            $arr2[] = $j;
        }

        for ($k=0;$k<=100;$k++){
            $i=array_rand($arr1);
            $p = array_rand($arr2);

            $sum = $arr1[$i] - $arr2[$p];
            $data = array(
                'leftnum'=>$arr1[$i],
                'rightnum'=>$arr2[$p],
                'symbol1'=>'-',
                'symbol2'=>'=',
                'sum'=>$sum,
                'rightsum'=>$sum,
                'anwser'=>'yes',
                'category'=>'2',
                'rank'=>'3',
            );

            M('countlike_questions')->data($data)->add();

            echo $arr1[$i].'-'.$arr2[$p].'='.$sum.'<br>';

        }


    }

    public function suiji(){
        exit;
        $info = M('countlike_questions')->where(array('rank'=>'3'))->select();

        $info = $this->shuffle_assoc($info);
        $info = array_merge($info);
       foreach ($info as $key=>$value){

           $data = array(
               'leftnum'=>$value['leftnum'],
               'symbol1'=>$value['symbol1'],
               'category'=>$value['category'],
               'rightsum'=>$value['rightsum'],
               'rank'=>$value['rank'],
               'anwser'=>$value['anwser'],
               'rightnum'=>$value['rightnum'],
               'symbol2'=>$value['symbol2'],
               'sum'=>$value['sum'],
           );

           M('countlike_questions1')->data($data)->add();
       }

    }

    public function gengzheng(){

        exit;
        $where['anwser'] = 'yes';
        $where['category'] = '2';
        $info = M('countlike_questions1')->where($where)->select();

        foreach ($info as $key=>$value){

            $update['symbol1'] = '-';
            M('countlike_questions1')->where(array('countlike_questions_id'=>$value['countlike_questions_id']))->save($update);
        }
    }

    public function test(){

        $member_id = 1;
        $info['count'] = M('countlike_rank')->sum('nums');
        $myrank = M('countlike_member')->where(array('countlike_member_id'=>'1'))->getField('rank');
        $where['rank'] = array('elt','1');
        $info['nowcount'] = M('countlike_rank')->where($where)->sum('nums');


        var_dump($info);
    }





}